<jsp:useBean id="productSearch" scope="request" type="java.lang.String"/>

<jsp:useBean id="commodityWindowStatic" scope="request" type="java.lang.Integer"/>
<%--
  Created by IntelliJ IDEA.
  User: kwc13
  Date: 2023-12-6
  Time: 上午 08:09
  To change this template use File | Settings | File Templates.
--%>
<!-- 标记为HTML格式 -->
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page isELIgnored="false" %>
<!-- 设置页面为Chain -->
<html lang="ch">
<head>
    <title>小米商城后台管理</title>
    <!-- 设置地址栏主题背景颜色 -->
    <meta name="theme-color" content="#000000">
    <!-- 页面描述 -->
    <meta name="description" content="页面描述信息">
    <!-- 移动端显示 -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <!-- 页面Logo -->
    <link rel="shortcut icon" href="http://localhost:8083/resource_packs/images/logo.png">
    <!-- CSS -->
    <link href="${pageContext.request.contextPath}/other/style/background/warehouse.css" rel="stylesheet"
          type="text/css"/>
    <script src="${pageContext.request.contextPath}/other/component/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/other/request/background/gaud.js"></script>
    <script src="${pageContext.request.contextPath}/other/scripts/background/warehouse.js"></script>
    <script src="${pageContext.request.contextPath}/other/request/background/commodity_warehouse.js"></script>
</head>
<body>
<div class="head">
    <div class="title">
        <span>仓库管理</span>
    </div>

    <div class="search">
        <div class="search-input">
            <label>
                <input type="text" placeholder="请输入仓库名称/仓库ID">
            </label>
        </div>
        <div class="search-img">
            <img src="http://localhost:8083/resource_packs/images/search_%23fff.png" alt="搜索">
        </div>
    </div>
</div>

<table class="employee-table">
    <tr>
        <th>
            ID
        </th>
        <th>
            仓库名称
        </th>
        <th>
            省
        </th>
        <th>
            市
        </th>
        <th>
            区
        </th>
        <th>
            详细地址
        </th>
        <th>
            仓库管理员
        </th>
        <th>
            仓库容量
        </th>
        <th>
            操作
        </th>
    </tr>
    <jsp:useBean id="warehousePage" scope="request" type="com.xm.entity.Page"/>
    <c:forEach var="warehouse" items="${warehousePage.data}">
        <tr>
            <td class="warehouse-id">
                    ${warehouse.warehouseId}
            </td>
            <td>
                    ${warehouse.warehouseName}
            </td>
            <td>
                    ${warehouse.warehouseProvince}
            </td>
            <td>
                    ${warehouse.warehouseCity}
            </td>
            <td>
                    ${warehouse.warehouseDistrict}
            </td>
            <td>
                    ${warehouse.warehouseFullAddress}
            </td>
            <td>
                    ${warehouse.administratorInformation.name}
            </td>
            <td>
                    ${warehouse.warehouseCapacity}
            </td>
            <td class="operate">
                <button class="view" warehouse-id="${warehouse.warehouseId}">查看</button>
            </td>
        </tr>
    </c:forEach>
</table>
<div class="pagination-function">
    <ul class="pagination">
        <c:if test="${warehousePage.pageNumber ne 1}">
            <li><a href="?menuId=101&pageNumber=1&pageSize=${warehousePage.pageSize}">首页</a></li>
            <li><a href="?menuId=101&pageNumber=${warehousePage.pageNumber - 1}&pageSize=${warehousePage.pageSize}">上一页</a></li>
        </c:if>

        <c:forEach var="page" begin="1" end="${warehousePage.totalPages}">
            <c:choose>
                <c:when test="${page eq warehousePage.pageNumber}">
                    <li><a href="?menuId=101&pageNumber=${page}&pageSize=${warehousePage.pageSize}" class="active">${page}</a></li>
                </c:when>
                <c:otherwise>
                    <c:if test="${page eq 1 or page eq warehousePage.totalPages or (page ge warehousePage.pageNumber - 2 and page le warehousePage.pageNumber + 2)}">
                        <li><a href="?menuId=101&pageNumber=${page}&pageSize=${warehousePage.pageSize}">${page}</a></li>
                    </c:if>
                    <c:if test="${page eq warehousePage.pageNumber - 3}">
                        <li><span>...</span></li>
                    </c:if>
                    <c:if test="${page eq warehousePage.pageNumber + 3}">
                        <li><span>...</span></li>
                    </c:if>
                </c:otherwise>
            </c:choose>
        </c:forEach>

        <c:if test="${warehousePage.pageNumber ne warehousePage.totalPages}">
            <li><a href="?menuId=101&pageNumber=${warehousePage.pageNumber + 1}&pageSize=${warehousePage.pageSize}">下一页</a></li>
            <li><a href="?menuId=101&pageNumber=${warehousePage.totalPages}&pageSize=${warehousePage.pageSize}">尾页</a></li>
        </c:if>
    </ul>
</div>

<!-- 弹窗：查看详情 -->
<div class="window" style="${commodityWindowStatic == 0 ? 'display: none' : 'display: block'}">
    <div class="pop-up-shade-layer"></div>
    <div class="pop-ups">
        <div class="pop-ups-title">
            <span>仓库详情</span>
            <img src="http://localhost:8083/resource_packs/images/pop_ups_closes.png"
                 alt="弹窗关闭" class="pop-ups-down">
        </div>
        <div class="searchCommodity">
            <div class="search-searchCommodity-input">
                <label>
                    <input type="text" placeholder="请输入商品名称/商品ID" value="${productSearch}">
                </label>
            </div>
            <div class="searchCommodity-img">
                <img src="http://localhost:8083/resource_packs/images/search_%23fff.png" alt="搜索">
            </div>
        </div>
        <table class="commodity-table">
            <tr>
                <th>
                    商品名称
                </th>
                <th>
                    库存
                </th>
                <th>
                    限购
                </th>
                <th>
                    操作
                </th>
            </tr>
            <jsp:useBean id="warehouseCommodityPage" scope="request" type="com.xm.entity.Page"/>
            <c:forEach var="commodities" items="${warehouseCommodityPage.data}" varStatus="commodityStatus">
                <tr>
                    <td class="commodity-id">
                            ${commodities.commodity.commodityName}
                    </td>
                    <td id="textCommodityInventory" class="inventory">${commodities.detailsInventory}</td>
                    <td id="textCommodityPurchase" class="purchase">${commodities.purchaseLimit}</td>
                    <td>
                        <button class="insert revise-button" index="${commodityStatus.index}" commodity-warehouse-id="${commodities.commodity.commodityId}">修改</button>
                    </td>
                </tr>
            </c:forEach>
        </table>
        <div class="pagination-function">
            <ul class="pagination-commodities">
                <c:if test="${warehouseCommodityPage.pageNumber ne 1}">
                    <li><a href="?menuId=101&commodityWindowStatic=1&warehousePageNumber=1&warehousePageSize=${warehouseCommodityPage.pageSize}">首页</a></li>
                    <li><a href="?menuId=101&commodityWindowStatic=1&warehousePageNumber=${warehouseCommodityPage.pageNumber - 1}&warehousePageSize=${warehouseCommodityPage.pageSize}">上一页</a></li>
                </c:if>

                <c:forEach var="page" begin="1" end="${warehouseCommodityPage.totalPages}">
                    <c:choose>
                        <c:when test="${page eq warehouseCommodityPage.pageNumber}">
                            <li><a href="?menuId=101&commodityWindowStatic=1&warehousePageNumber=${page}&warehousePageSize=${warehouseCommodityPage.pageSize}" class="active">${page}</a></li>
                        </c:when>
                        <c:otherwise>
                            <c:if test="${page eq 1 or page eq warehouseCommodityPage.totalPages or (page ge warehouseCommodityPage.pageNumber - 2 and page le warehouseCommodityPage.pageNumber + 2)}">
                                <li><a href="?menuId=101&commodityWindowStatic=1&warehousePageNumber=${page}&warehousePageSize=${warehouseCommodityPage.pageSize}">${page}</a></li>
                            </c:if>
                            <c:if test="${page eq warehouseCommodityPage.pageNumber - 3}">
                                <li><span>...</span></li>
                            </c:if>
                            <c:if test="${page eq warehouseCommodityPage.pageNumber + 3}">
                                <li><span>...</span></li>
                            </c:if>
                        </c:otherwise>
                    </c:choose>
                </c:forEach>

                <c:if test="${warehouseCommodityPage.pageNumber ne warehouseCommodityPage.totalPages}">
                    <li><a href="?menuId=101&commodityWindowStatic=1&warehousePageNumber=${warehouseCommodityPage.pageNumber + 1}&warehousePageSize=${warehouseCommodityPage.pageSize}">下一页</a></li>
                    <li><a href="?menuId=101&commodityWindowStatic=1&warehousePageNumber=${warehouseCommodityPage.totalPages}&warehousePageSize=${warehouseCommodityPage.pageSize}">尾页</a></li>
                </c:if>
            </ul>
        </div>
    </div>
</div>

</body>
</html>
